<?php


/**
 * Base class that represents a query for the 'w_lp_vv_WizPrac' table.
 *
 *
 *
 * @method LpEmployeesPositionsQuery orderByLogoId($order = Criteria::ASC) Order by the NR_OS column
 * @method LpEmployeesPositionsQuery orderByPositionId($order = Criteria::ASC) Order by the ID_STAN column
 * @method LpEmployeesPositionsQuery orderByUnitId($order = Criteria::ASC) Order by the ID_JEDN column
 * @method LpEmployeesPositionsQuery orderByEmail($order = Criteria::ASC) Order by the EMAIL column
 *
 * @method LpEmployeesPositionsQuery groupByLogoId() Group by the NR_OS column
 * @method LpEmployeesPositionsQuery groupByPositionId() Group by the ID_STAN column
 * @method LpEmployeesPositionsQuery groupByUnitId() Group by the ID_JEDN column
 * @method LpEmployeesPositionsQuery groupByEmail() Group by the EMAIL column
 *
 * @method LpEmployeesPositionsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method LpEmployeesPositionsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method LpEmployeesPositionsQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method LpEmployeesPositionsQuery leftJoinPositions($relationAlias = null) Adds a LEFT JOIN clause to the query using the Positions relation
 * @method LpEmployeesPositionsQuery rightJoinPositions($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Positions relation
 * @method LpEmployeesPositionsQuery innerJoinPositions($relationAlias = null) Adds a INNER JOIN clause to the query using the Positions relation
 *
 * @method LpEmployeesPositionsQuery leftJoinUnits($relationAlias = null) Adds a LEFT JOIN clause to the query using the Units relation
 * @method LpEmployeesPositionsQuery rightJoinUnits($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Units relation
 * @method LpEmployeesPositionsQuery innerJoinUnits($relationAlias = null) Adds a INNER JOIN clause to the query using the Units relation
 *
 * @method LpEmployeesPositionsQuery leftJoinEmployees($relationAlias = null) Adds a LEFT JOIN clause to the query using the Employees relation
 * @method LpEmployeesPositionsQuery rightJoinEmployees($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Employees relation
 * @method LpEmployeesPositionsQuery innerJoinEmployees($relationAlias = null) Adds a INNER JOIN clause to the query using the Employees relation
 *
 * @method LpEmployeesPositions findOne(PropelPDO $con = null) Return the first LpEmployeesPositions matching the query
 * @method LpEmployeesPositions findOneOrCreate(PropelPDO $con = null) Return the first LpEmployeesPositions matching the query, or a new LpEmployeesPositions object populated from the query conditions when no match is found
 *
 * @method LpEmployeesPositions findOneByLogoId(string $NR_OS) Return the first LpEmployeesPositions filtered by the NR_OS column
 * @method LpEmployeesPositions findOneByPositionId(string $ID_STAN) Return the first LpEmployeesPositions filtered by the ID_STAN column
 * @method LpEmployeesPositions findOneByUnitId(string $ID_JEDN) Return the first LpEmployeesPositions filtered by the ID_JEDN column
 * @method LpEmployeesPositions findOneByEmail(string $EMAIL) Return the first LpEmployeesPositions filtered by the EMAIL column
 *
 * @method array findByLogoId(string $NR_OS) Return LpEmployeesPositions objects filtered by the NR_OS column
 * @method array findByPositionId(string $ID_STAN) Return LpEmployeesPositions objects filtered by the ID_STAN column
 * @method array findByUnitId(string $ID_JEDN) Return LpEmployeesPositions objects filtered by the ID_JEDN column
 * @method array findByEmail(string $EMAIL) Return LpEmployeesPositions objects filtered by the EMAIL column
 *
 * @package    propel.generator.lp.om
 */
abstract class LpBaseEmployeesPositionsQuery extends ModelCriteria
{
    /**
     * Initializes internal state of LpBaseEmployeesPositionsQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vw_lp', $modelName = 'LpEmployeesPositions', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new LpEmployeesPositionsQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     LpEmployeesPositionsQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return LpEmployeesPositionsQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof LpEmployeesPositionsQuery) {
            return $criteria;
        }
        $query = new LpEmployeesPositionsQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj = $c->findPk(array(12, 34), $con);
     * </code>
     *
     * @param array $key Primary key to use for the query
                         A Primary key composition: [$NR_OS, $ID_JEDN]
     * @param     PropelPDO $con an optional connection object
     *
     * @return   LpEmployeesPositions|LpEmployeesPositions[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = LpEmployeesPositionsPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(LpEmployeesPositionsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   LpEmployeesPositions A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT NR_OS, ID_STAN, ID_JEDN, EMAIL FROM w_lp_vv_WizPrac WHERE NR_OS = :p0 AND ID_JEDN = :p1';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key[0], PDO::PARAM_STR);
            $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new LpEmployeesPositions();
            $obj->hydrate($row);
            LpEmployeesPositionsPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return LpEmployeesPositions|LpEmployeesPositions[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|LpEmployeesPositions[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return LpEmployeesPositionsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {
        $this->addUsingAlias(LpEmployeesPositionsPeer::NR_OS, $key[0], Criteria::EQUAL);
        $this->addUsingAlias(LpEmployeesPositionsPeer::ID_JEDN, $key[1], Criteria::EQUAL);

        return $this;
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return LpEmployeesPositionsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {
        if (empty($keys)) {
            return $this->add(null, '1<>1', Criteria::CUSTOM);
        }
        foreach ($keys as $key) {
            $cton0 = $this->getNewCriterion(LpEmployeesPositionsPeer::NR_OS, $key[0], Criteria::EQUAL);
            $cton1 = $this->getNewCriterion(LpEmployeesPositionsPeer::ID_JEDN, $key[1], Criteria::EQUAL);
            $cton0->addAnd($cton1);
            $this->addOr($cton0);
        }

        return $this;
    }

    /**
     * Filter the query on the NR_OS column
     *
     * Example usage:
     * <code>
     * $query->filterByLogoId('fooValue');   // WHERE NR_OS = 'fooValue'
     * $query->filterByLogoId('%fooValue%'); // WHERE NR_OS LIKE '%fooValue%'
     * </code>
     *
     * @param     string $logoId The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpEmployeesPositionsQuery The current query, for fluid interface
     */
    public function filterByLogoId($logoId = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($logoId)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $logoId)) {
                $logoId = str_replace('*', '%', $logoId);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(LpEmployeesPositionsPeer::NR_OS, $logoId, $comparison);
    }

    /**
     * Filter the query on the ID_STAN column
     *
     * Example usage:
     * <code>
     * $query->filterByPositionId('fooValue');   // WHERE ID_STAN = 'fooValue'
     * $query->filterByPositionId('%fooValue%'); // WHERE ID_STAN LIKE '%fooValue%'
     * </code>
     *
     * @param     string $positionId The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpEmployeesPositionsQuery The current query, for fluid interface
     */
    public function filterByPositionId($positionId = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($positionId)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $positionId)) {
                $positionId = str_replace('*', '%', $positionId);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(LpEmployeesPositionsPeer::ID_STAN, $positionId, $comparison);
    }

    /**
     * Filter the query on the ID_JEDN column
     *
     * Example usage:
     * <code>
     * $query->filterByUnitId('fooValue');   // WHERE ID_JEDN = 'fooValue'
     * $query->filterByUnitId('%fooValue%'); // WHERE ID_JEDN LIKE '%fooValue%'
     * </code>
     *
     * @param     string $unitId The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpEmployeesPositionsQuery The current query, for fluid interface
     */
    public function filterByUnitId($unitId = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($unitId)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $unitId)) {
                $unitId = str_replace('*', '%', $unitId);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(LpEmployeesPositionsPeer::ID_JEDN, $unitId, $comparison);
    }

    /**
     * Filter the query on the EMAIL column
     *
     * Example usage:
     * <code>
     * $query->filterByEmail('fooValue');   // WHERE EMAIL = 'fooValue'
     * $query->filterByEmail('%fooValue%'); // WHERE EMAIL LIKE '%fooValue%'
     * </code>
     *
     * @param     string $email The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpEmployeesPositionsQuery The current query, for fluid interface
     */
    public function filterByEmail($email = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($email)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $email)) {
                $email = str_replace('*', '%', $email);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(LpEmployeesPositionsPeer::EMAIL, $email, $comparison);
    }

    /**
     * Filter the query by a related LpPositions object
     *
     * @param   LpPositions|PropelObjectCollection $positions The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   LpEmployeesPositionsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByPositions($positions, $comparison = null)
    {
        if ($positions instanceof LpPositions) {
            return $this
                ->addUsingAlias(LpEmployeesPositionsPeer::NR_OS, $positions->getLogoId(), $comparison);
        } elseif ($positions instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(LpEmployeesPositionsPeer::NR_OS, $positions->toKeyValue('PrimaryKey', 'LogoId'), $comparison);
        } else {
            throw new PropelException('filterByPositions() only accepts arguments of type LpPositions or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Positions relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return LpEmployeesPositionsQuery The current query, for fluid interface
     */
    public function joinPositions($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Positions');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Positions');
        }

        return $this;
    }

    /**
     * Use the Positions relation Positions object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   LpPositionsQuery A secondary query class using the current class as primary query
     */
    public function usePositionsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinPositions($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Positions', 'LpPositionsQuery');
    }

    /**
     * Filter the query by a related LpUnits object
     *
     * @param   LpUnits|PropelObjectCollection $units The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   LpEmployeesPositionsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByUnits($units, $comparison = null)
    {
        if ($units instanceof LpUnits) {
            return $this
                ->addUsingAlias(LpEmployeesPositionsPeer::ID_JEDN, $units->getId(), $comparison);
        } elseif ($units instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(LpEmployeesPositionsPeer::ID_JEDN, $units->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByUnits() only accepts arguments of type LpUnits or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Units relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return LpEmployeesPositionsQuery The current query, for fluid interface
     */
    public function joinUnits($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Units');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Units');
        }

        return $this;
    }

    /**
     * Use the Units relation Units object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   LpUnitsQuery A secondary query class using the current class as primary query
     */
    public function useUnitsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinUnits($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Units', 'LpUnitsQuery');
    }

    /**
     * Filter the query by a related LpEmployees object
     *
     * @param   LpEmployees|PropelObjectCollection $employees  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   LpEmployeesPositionsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByEmployees($employees, $comparison = null)
    {
        if ($employees instanceof LpEmployees) {
            return $this
                ->addUsingAlias(LpEmployeesPositionsPeer::NR_OS, $employees->getLogoId(), $comparison);
        } elseif ($employees instanceof PropelObjectCollection) {
            return $this
                ->useEmployeesQuery()
                ->filterByPrimaryKeys($employees->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByEmployees() only accepts arguments of type LpEmployees or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Employees relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return LpEmployeesPositionsQuery The current query, for fluid interface
     */
    public function joinEmployees($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Employees');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Employees');
        }

        return $this;
    }

    /**
     * Use the Employees relation Employees object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   LpEmployeesQuery A secondary query class using the current class as primary query
     */
    public function useEmployeesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinEmployees($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Employees', 'LpEmployeesQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   LpEmployeesPositions $employeesPositions Object to remove from the list of results
     *
     * @return LpEmployeesPositionsQuery The current query, for fluid interface
     */
    public function prune($employeesPositions = null)
    {
        if ($employeesPositions) {
            $this->addCond('pruneCond0', $this->getAliasedColName(LpEmployeesPositionsPeer::NR_OS), $employeesPositions->getLogoId(), Criteria::NOT_EQUAL);
            $this->addCond('pruneCond1', $this->getAliasedColName(LpEmployeesPositionsPeer::ID_JEDN), $employeesPositions->getUnitId(), Criteria::NOT_EQUAL);
            $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
        }

        return $this;
    }

}
